Option Explicit
Sub H_Sample012()
    'Microsoft ActiveX Data Objects 2.X Library ѷӳ]w
    'ոH_Data.mdb H_Tbl01
    Dim myPcsh As PivotCache
    Dim myPtbl As PivotTable
    Dim myPfld As PivotField
    Dim myCon  As New ADODB.Connection
    Dim myRst  As New ADODB.Recordset
    Dim mySht  As Worksheet
    Dim myStr  As String
    Dim i      As Long
    With myCon
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0"
        .Open ThisWorkbook.Path & "\H_Data.mdb"	'w¦
    End With
    myRst.Open "H_Tbl01", myCon				'w¦
    Set myPcsh = ThisWorkbook.PivotCaches.Add( _
    SourceType:=xlExternal)
    Set myPcsh.Recordset = myRst
    Set mySht = ThisWorkbook.Worksheets(1)		'N
    mySht.Cells.Clear
    Set myPtbl = myPcsh.CreatePivotTable( _
    TableDestination:=mySht.Range("a1"))
    With myPtbl
        .PivotFields("").Orientation = xlColumnField
        For i = 4 To 7
            Set myPfld = .PivotFields(i)
            With myPfld
                myStr = .Name
                .Orientation = xlDataField
                .Caption = myStr & "Ave"
                .Function = xlAverage
                .NumberFormat = "0.00_ "
            End With
        Next
    End With
    'Excel2002SOBz
    'ActiveWorkbook.ShowPivotTableFieldList = False
    myRst.Close
    myCon.Close
    Set myRst = Nothing						'
    Set myCon = Nothing
    Set mySht = Nothing
    Set myPcsh = Nothing
    Set myPtbl = Nothing
    Set myPfld = Nothing
End Sub
